function addMethod(object, name, fn) {
    const old = object[name]
    object[name] = function (...args) {
        if (args.length === fn.length) {
            return fn.apply(this, args)
        } else if (typeof old === 'function') {
            return old.apply(this, args)
        }
    }
}

const searcher = {}
addMethod(searcher, 'getUser', () => {
    console.log('查询所有用户')
})

addMethod(searcher, 'getUser', (firstName) => {
    console.log('按照姓名查询用户')
})

addMethod(searcher, 'getUser', (firstName, sex) => {
    console.log('按照姓名和性别查询用户')
})

searcher.getUser(1, 2)
